package com.zgm.ch04.applicationContext._9_2;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ContextAwareDemo implements ApplicationContextAware {

	private ApplicationContext ctx;
	
	public static void main(String[] args){
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("com/zgm/ch04/applicationContext/_9_2/_9_2-context.xml");
		ContextAwareDemo demo = (ContextAwareDemo) applicationContext.getBean("contextAware");
		
		demo.displayAppContext();
		
	}
	
	public void displayAppContext(){
		System.out.println("显示ctx：" + ctx);
	}

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.ctx = applicationContext;
	}
	
	
	
}
